def is_sink(A,k):
    n=len(A)
    for i in xrange(n):
        if A[k][i]!=0:
            return False
    for i in xrange(n):
        if A[i][k]!=1 and i!=k:
            return False
    return True

def check_universal_sink(A):
    n=len(A)
    i=0
    j=0
    while i<n and j<n:
        if A[i][j]==0:
            j+=1
        else:
            i+=1
    if i==n: #i may out range(n)
        print 'No universal sink'
    if is_sink(A,i)==False:
        print 'No universal sink'
    else:
        print 'Universal sink:',i

if __name__=='__main__':
    A=[[0,0,1,1],\
       [0,0,1,1],\
       [1,0,0,1],\
       [0,0,0,0]]
    check_universal_sink(A)
